-
Notifications
You must be signed in to change notification settings - Fork 211
Demo: X-ray Absorption Spectroscopy #1390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
colinjdale
wants to merge
108
commits into
master
Choose a base branch
from
demo_xas
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+2,180
−0
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Thank you for opening this pull request. You can find the built site at this link. Deployment Info:
Note: It may take several minutes for updates to this pull request to be reflected on the deployed site. |
Implemented minor comments. Co-authored-by: Alvaro Ballon <91897656+alvaro-at-xanadu@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Title:
X-ray absorption spectroscopy simulation in the time domain
Summary:
This demo shows how to implement a time-domain XAS simulation algorithm for a small instance of an$H_2$ molecule. The algorithm is based on Fomichev et al. 2025, omitting some of the optimizations in that paper. XAS is introduced as well as why simulating XAS could be a promising use for early fault-tolerant quantum computers. The algorithm is described, and then implemented in PennyLane, with the time-domain and spectrum output plotted. Additional optimizations are discussed at the end.
Relevant references:
"Fast simulations of X-ray absorption spectroscopy for battery materials on a quantum computer" by Stepan Fomichev, Pablo A. M. Casares, Jay Soni, Utkarsh Azad, Alexander Kunitsa, Arne-Christian Voigt, Jonathan E. Mueller, Juan Miguel Arrazola, (2025) https://arxiv.org/abs/2506.15784
"Simulating X-ray absorption spectroscopy of battery materials on a quantum computer", by Stepan Fomichev, Kasra Hejazi, Ignacio Loaiza, Modjtaba Shokrian Zini, Alain Delgado, Arne-Christian Voigt, Jonathan E. Mueller, Juan Miguel Arrazola (2024) https://arxiv.org/abs/2405.11015
Possible Drawbacks:
Large knowledge overhead
The demo makes extensive reference to previous quantum chemistry demos: Using PennyLane with PySCF and OpenFermion, Initial state preparation for quantum chemistry, and How to build compressed double-factorized Hamiltonians. This increases the overhead for the reader to understand the demo (IMO).
Example too simple/not relevant
$H_2$ is not a battery material, but calculating the ground state for some small cluster of a relevant material would take a long time, and is infeasible for a demo. I tried to use an $N_2$ molecule, but $H_2$ .
factorize
seemed to produce different results on my local computer and on the website, so I changed back toPennyLane factorization requires fine-tuned parameters
$N_2$ active space, where I had to scan a large parameter space to find the number of factors that worked. The implementation in Stepan and Pablo's xas_simulation repo works much better than the PennyLane implementation. I'm not sure why the PennyLane factorization is so reliant on a very specific number of factors. It seems to be reliable for $H_2$ , which is why I switched back to it.
qml.qchem.factorize
does not seem to reliably produce a factorized Hamiltonian that works well in the algorithm unless the number of factors and number of steps of optimization are set very specifically. This was particularly an issue for anMolecular orbital coefficient sign flip-flop/inconsistency between implementations$N_2$ active space, I ended up changing the bond length to 1.0 Angstrom from 1.077 because that seemed to produce more stable results.
The molecular orbital coefficients (MO coeffs) that are calculated in PySCF, PennyLane and OpenFermion end up slightly different from each other. Because CASCI methods are used to find the ground state in the active space, I had to overwrite the PySCF MO coeffs with the PennyLane calculated MO coeffs to match the ones used in the Hamiltonian and the dipole operator. I believe the MO coeffs have to be the same in all calculations for the result to be correct. However,
qml.qchem.scf
does not consistently produce the same MO coeffs, and I believe the same is true for PySCF. But, the beyond Hartree-Fock calculation methods in PySCF pull from the initial Hartree Fock instance, so the MO coefficients remain the same. However in PennyLane, the MO coeffs are recalculated whendipole_moment
andelectron_integrals
are called, so I'm not sure if they will always give the same values. When trying anRelated GitHub Issues:
If you are writing a demonstration, please answer these questions to facilitate the marketing process.
To show off a recent Xanadu paper. This paper is of interest because it describes a quantum algorithm that could have near-term industrial utility (battery material simulation). The implementation of this algorithm in PennyLane is relatively simple, due to the functions in the quantum chemistry module of PennyLane. Showing off the utility of these functions is a main focus of the demo.
Chemistry researchers, anyone interested in Hamiltonian simulation algorithms.
X-ray absorption spectroscopy, Hamiltonian simulation, battery research, compressed double-factorized Hamiltonians, time-domain simulation, optimization, product formulas, commercial application
(more details here)